﻿using System.Collections.Generic;

using Bootstrap5.Abstractions;

namespace Bootstrap5.Design;

/// <summary>
/// A provider witch is to build the bootstrap triggers using 'data-bs-*' data attribute.
/// </summary>
public class TriggerProvider
{
	Dictionary<string,object> _triggers = new();

	public TriggerProvider Dismiss(DismissName e)
    {
		return SetEvent("dismiss", e.GetEnumDefaultValue());
	}

	public TriggerProvider Toggle(ToggleName e)
	{
		return SetEvent("toggle", e.GetEnumDefaultValue());
	}
	public TriggerProvider Target(string value)
    {
		return SetEvent("target", value);
    }

	internal TriggerProvider SetEvent(string name,object value)
    {
		if(value is null)
        {
			return this;
        }
		_triggers[name] = value;
		return this;
    }

	public void BuildTrigger(BootstrapTriggerBuilder builder)
    {
        foreach (var item in _triggers)
        {
			builder.SetData(item.Key, item.Value);
        }
    }
}
